/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.hd.test.mybatis;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

/**
 * @filename Init
 * @author hwu
 * @date 2016-4-9 @copyright（C） 深圳市宏电技术股份有限公司
 * @encoding UTF-8
 * @repository http://172.16.22.244:8081/nexus/content/repositories
 * @description 功能说明
 */
public class SystemInit {

	public static void init() {
		try {
			String rootPath = ClassLoader.class.getResource("/").getPath();
			int index = rootPath.indexOf("target");
			rootPath = rootPath.substring(1, index);
			String[] applicationPath = { rootPath + "src/main/resources/applicationContext.xml" };

			// 启动spring环境
			ApplicationContext content = new FileSystemXmlApplicationContext(applicationPath);
			Object object = content.getBean("userService");
			System.out.println(object.hashCode());
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}

	public static void main(String[] args) {
		SystemInit init = new SystemInit();
		init.init();
	}
}
